package com.company.woye.checkmakesure;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.company.woye.R;
import com.company.woye.base.BaseActivity;
import com.company.woye.checkmakesure.adapter.MakeSureDeLvBottomAdapter;
import com.company.woye.checkmakesure.bean.LuBuDetailBean;
import com.company.woye.utils.Toaster;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class MakeDetailDActivity extends BaseActivity {

    @BindView(R.id.iv_on_package_back)
    ImageView ivOnPackageBack;
    @BindView(R.id.tv_on_package_back)
    TextView tvOnPackageBack;
    @BindView(R.id.tv_sure)
    TextView tvSure;
    @BindView(R.id.tv_on_package_sure)
    TextView tvOnPackageSure;
    @BindView(R.id.tv_on_package_search)
    TextView tvOnPackageSearch;
    @BindView(R.id.tv_look_process)
    TextView tvLookProcess;
    @BindView(R.id.tv_size)
    TextView tvSize;
    @BindView(R.id.tv_kds)
    TextView tvKds;
    @BindView(R.id.tv_bdjs)
    TextView tvBdjs;
    @BindView(R.id.tv_zps)
    TextView tvZps;
    @BindView(R.id.tv_jhrq)
    TextView tvJhrq;
    @BindView(R.id.tv_sz)
    TextView tvSz;
    @BindView(R.id.tv_gy)
    TextView tvGy;
    @BindView(R.id.ll2)
    LinearLayout ll2;
    @BindView(R.id.lv_bottom)
    ListView lvBottom;
    @BindView(R.id.ll_on_package_summary)
    LinearLayout llOnPackageSummary;
    @BindView(R.id.rl)
    RelativeLayout rl;
    ArrayList<LuBuDetailBean.DataBean.DbhListBean> dbhListBeans = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int setLayoutId() {
        return R.layout.activity_make_detail_d;
    }

    @Override
    public void initView() {
        Intent intent = getIntent();
        if (intent != null) {
            dbhListBeans = (ArrayList<LuBuDetailBean.DataBean.DbhListBean>) intent.getSerializableExtra("data");
            if (dbhListBeans != null && dbhListBeans.size() > 0) {
                lvBottom.setAdapter(new MakeSureDeLvBottomAdapter(this, dbhListBeans));
                int allKds = 0, allBdjs = 0, allZps = 0;
                for (int i = 0; i < dbhListBeans.size(); i++) {
                    if (!TextUtils.isEmpty(dbhListBeans.get(i).getKds() + "")) {
//                        allKds += dbhListBeans.get(i).getKds();

                    }
                    if (!TextUtils.isEmpty(dbhListBeans.get(i).getBdjs() + "")) {
//                        allBdjs += dbhListBeans.get(i).getBdjs();

                    }
                    if (!TextUtils.isEmpty(dbhListBeans.get(i).getZps() + "")) {
//                        allZps += dbhListBeans.get(i).getZps();
                    }
                }
                tvKds.setText(allKds + "");
                tvBdjs.setText(allBdjs + "");
                tvZps.setText(allZps + "");

            } else {
                Toaster.showLong(MakeDetailDActivity.this, "任务单信息为空");
            }
        }
    }

    @OnClick({R.id.iv_on_package_back, R.id.tv_on_package_back})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_on_package_back:
            case R.id.tv_on_package_back:
                finish();
                break;
        }
    }
}
